<?php
/**
 * Login_Data_Loggeddatacheckout
 * @author Adrian Stolarski
 */
class Login_Data_Loggeddatacheckout implements Login_Data_Mainable {
    
    /**
     *
     * @var type $database
     * database handler
     */
    public $database;
    
    /**
     *
     * @var type $database_query
     */
    public $database_query;
    
    /**
     * constructor()
     */
    public function __construct(){
        $this->database = new Core_Driver_MysqlImproved;
    }
    
    /**
     * main()
     * check user data
     * @param array $variables
     * @return type user_id
     */
    public function main(array $variables = null) {
        $this->database->connect();
        $user_email = $this->database->escape($variables['post']['user_email']);
        $user_password = $this->database->escape($variables['post']['user_password']);
        $this->database_query = "SELECT id FROM users_data WHERE user_email='$user_email' AND user_password='$user_password' LIMIT 1;";
        $this->database->prepare($this->database_query);
        $this->database->query();
        $user_data = $this->database->fetch('array');
        $user_id = $user_data['id'];
        return $user_id;
    }
}
